<?php

include 'confidential_settings_heliohost.php';
// This include contains 5 variables:
//  - db_name: database name
//  - table_name_x: table name
//  - username: username
//  - password: password
//  - localhost: host name


$val = $_GET['val'];
$tmp_val = $val;
$date_str = date("Ymd");
$time_str = date('H:m');

// === Add to database ===
// example: http://shredcat.zxq.net/my_php/add_wat_value.php?val=0
$str = 'http://shredcat.zxq.net/my_php/add_wat_value.php?val=' . $tmp_val;
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $str); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$data = curl_exec($ch); 
curl_close($ch); 

// === Add to local database ===
$dbh=mysql_connect ($localhost, $username, $password) or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name) or die(mysql_error()); 
$val = $_GET['val'];
$val = mysql_real_escape_string($val);
mysql_query("INSERT INTO $table_name_wat
(val) VALUES($val) ") or die(mysql_error());  
mysql_close($dbh);

// Send response
echo "[OK]";

?>